package com.handinfo.uimenu.window;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.Vector;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;

import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.engine.GameMIDlet;
import com.handinfo.engine.GameManager;
import com.handinfo.game.ActorRole;
import com.handinfo.uimenu.UIAbstractWindow;
import com.handinfo.uimenu.UIListener;
import com.handinfo.uimenu.UIManager;
import com.handinfo.uimenu.UIMessageBox;
import com.handinfo.uimenu.UIPalette;
import com.handinfo.uimenu.UIPopmenu;
import com.handinfo.uimenu.UITools;
import com.handinfo.uimenu.UIWindowFactory;
import com.handinfo.util.Tools;
import com.test.touch.GameTouchManager;

public class UISocialWindow extends UIAbstractWindow
{
	private int whileWindowID = -1;
	public static int whileLogic = 0; //0为正常进入  1为写信进入

	public UISocialWindow(int id)
	{
		super(id);
		whileWindowID = id;
		setBounds(UITools.X_BG, UITools.Y_BG, UITools.W_BG, UITools.H_BG);
		initImage();
	}
	
	

	protected void onTouchRect(int[][] rect, int touchid) {
//		super.onTouchRect(rect, touchid);
		if (rect == page) {
			switch(touchid) {
			case 0:
				GameTouchManager.keyPressedLSoft();
				break;
			case 1:
				GameTouchManager.keyPressedRSoft();
				break;
			case 2:
				GameTouchManager.keyPressedNum(1);
				break;
			}
		} else {
			if (memberIndex == touchid) {
				GameTouchManager.keyPressedFire();	
			} else {
				memberIndex = touchid;
			}
			
		}
	}
	
	public void registerTouch() {
		registerNormalSoft();
		initTouchRect(page);
		Vector list = GameManager.getInstance().m_social_list;
		if (list == null || list.size() == 0)
			return;
		int size = list.size();
		int[][]rect = new int[size][];
		for (int i=0;i<size;i++) {
			rect[i] = new int[]{LIST_FRAME_X, LIST_FRAME_Y + LIST_RECT_H * (i),
					LISTNAME_NAME_WIDTH + (LISTNAME_OTHER_WIDTH + LIST_SPACE) * 3, LIST_RECT_H};
		}
		initTouchRect(rect);
	}
	
	int[][] page = new int[][]{
			{187,249,43,24},//page left
			{253,249,43,24},//page right
			{206,275,69,20},//key 1
	};
	
	/**
	 * 开启社交列表菜单
	 * 2012-3-30 下午05:24:29
	 */
	public static void openSocialList()
	{
		Tools.debugPrintln("社交  ");
		String[] items = new String[] { "  1.好友", "  2.仇敌", "  3.夫妻", "  4.结义", "  5.师徒", " 6.黑名单",
				"  0.返回" };
		GameManager.getInstance().m_role.stay(GameManager.getInstance().m_role.m_direct);
		UIPopmenu socialPopwin = (UIPopmenu) UIManager.getInstance().createWindow(
				UIWindowFactory.WINDOW_POPMENU);
		socialPopwin.setPopmenus(items);
		socialPopwin.addListener(getSoacialSubMenuListener(socialPopwin));
	}

	/**
	 * 开启好友列表
	 * 2012-4-18 下午 15:54
	 */
	public static void openFriendWindow()
	{

		UISocialWindow socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
				UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
		GameManager.getInstance().m_game_message.sendSocialList(GameManager.SOCIAL_TYPE_FRIEND, 0,
				socialWin.memberPageNum);
	}

	/**
	 * 开启攻伐列表
	 * 2012-5-2
	 */
	public static void openGongFaWindow()
	{
		UISocialWindow socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
				UIWindowFactory.WINDOW_ID_DONGFU_GONGFA);
		GameManager.getInstance().m_game_message.sendDongFuGongFaList(0, socialWin.memberPageNum);
	}

	public static void opensSocialWindow(byte type)
	{
		UISocialWindow socialWin = null;
		switch (type) {
			case GameManager.SOCIAL_TYPE_FRIEND:
				socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
				GameManager.getInstance().m_game_message.sendSocialList(GameManager.SOCIAL_TYPE_FRIEND, 0,
						socialWin.memberPageNum);
				break;
			case GameManager.SOCIAL_TYPE_BLACKLIST:
				socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_ID_SOCIAL_BLACK);
				GameManager.getInstance().m_game_message.sendSocialList(GameManager.SOCIAL_TYPE_BLACKLIST, 0,
						socialWin.memberPageNum);
				break;
			case GameManager.SOCIAL_TYPE_ENEMY:
				socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY);
				GameManager.getInstance().m_game_message.sendEnemyList((short) 0, (short) socialWin.memberPageNum);
				break;
			default:
				break;
		}
		UISocialWindow.whileLogic = 0;
	}

	public byte isWhileFromUI = -1;

	/**
	 * 从设计界面
	 * @param SocialType 具体界面的类型 //0:好友 1：仇敌 5：黑名单
	 */
	public static void MarketToSocial(int SocialType)
	{
		openSocialReturn(SocialType, (byte) 2);
	}

	/**
	 * 从写信到设计界面
	 * @param SocialType 具体界面的类型 //0:好友 1：仇敌 5：黑名单
	 */
	public static void MailToSocial(int SocialType)
	{
		openSocialReturn(SocialType, (byte) 1);
	}

	private static void openSocialReturn(int SocialType, byte from)
	{
		UISocialWindow socialWin = null;
		switch (SocialType) {
			case 0:// 好友
				socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
				GameManager.getInstance().m_game_message.sendSocialList(GameManager.SOCIAL_TYPE_FRIEND, 0,
						socialWin.memberPageNum);
				break;
			case 1:// 仇敌
				socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY);
				GameManager.getInstance().m_game_message.sendEnemyList((short) 0, (short) socialWin.memberPageNum);
				break;
			case 2:// 夫妻
				break;
			case 3:// 结义
				break;
			case 4:// 师徒
				break;
			case 5:// 黑名单
				socialWin = (UISocialWindow) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_ID_SOCIAL_BLACK);
				GameManager.getInstance().m_game_message.sendSocialList(GameManager.SOCIAL_TYPE_BLACKLIST, 0,
						socialWin.memberPageNum);
				break;
		}
		if (socialWin != null) {
			socialWin.isWhileFromUI = from;
		}
		whileLogic = 1;
	}

	/**
	 * 社交子选项监听
	 * @param win
	 * @return
	 */
	private static UIListener getSoacialSubMenuListener(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{

				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
					opensSocialWindow(GameManager.SOCIAL_TYPE_FRIEND);
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
					opensSocialWindow(GameManager.SOCIAL_TYPE_ENEMY);
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
					GameManager.getInstance().addSystemInfo(
							GameManager.SYSTEM_INFO_TYPE_A, "暂未开启,敬请期待!");
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
					GameManager.getInstance().addSystemInfo(
							GameManager.SYSTEM_INFO_TYPE_A, "暂未开启,敬请期待!");
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {
					GameManager.getInstance().addSystemInfo(
							GameManager.SYSTEM_INFO_TYPE_A, "暂未开启,敬请期待!");
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY6)) {
					opensSocialWindow(GameManager.SOCIAL_TYPE_BLACKLIST);
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0:// 好友
							opensSocialWindow(GameManager.SOCIAL_TYPE_FRIEND);
							break;
						case 1:// 仇敌
							opensSocialWindow(GameManager.SOCIAL_TYPE_ENEMY);
							break;
						case 2:// 夫妻
							GameManager.getInstance().addSystemInfo(
									GameManager.SYSTEM_INFO_TYPE_A, "暂未开启,敬请期待!");
							break;
						case 3:// 结义
							GameManager.getInstance().addSystemInfo(
									GameManager.SYSTEM_INFO_TYPE_A, "暂未开启,敬请期待!");
							break;
						case 4:// 师徒
							GameManager.getInstance().addSystemInfo(
									GameManager.SYSTEM_INFO_TYPE_A, "暂未开启,敬请期待!");
							break;
						case 5:// 黑名单
							opensSocialWindow(GameManager.SOCIAL_TYPE_BLACKLIST);
							break;
						case 6:// 返回
							UIManager.getInstance().removeWindow(win);
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	private void getLogicSocialToMail()
	{
		if (isWhileFromUI == 1) {
			UIMail.sendMailToPlayer(getIndexName());
		}
		else if (isWhileFromUI == 2) {
			UIMarket.gotoPresent(getIndexID(), getIndexName());
		}
		close();
	}

	private String title = "";
	private String butten = "";

	protected void paintContent(Graphics g)
	{
		UITools.clearScreen(g); // 清屏
		// 绘制背景
		switch (whileWindowID) {
			case UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND: // 好友列表
				title = "好友";
				butten = "1.添加好友";
				UITools.paintBackGround(g, m_x, m_y, m_w, m_h, title, butten, true, true);
				paintFriendList(g);
				break;
			case UIWindowFactory.WINDOW_ID_SOCIAL_BLACK: // 黑名单列表
				title = "黑名单";
				butten = "1.添加黑名单";
				UITools.paintBackGround(g, m_x, m_y, m_w, m_h, title, butten, true, true);
				paintBliackList(g);
				break;
			case UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY: // 仇敌列表
				title = "仇敌";
				butten = "";
				UITools.paintBackGround(g, m_x, m_y, m_w, m_h, title, butten, true, true);
				if (m_enemyStatus == 0) {
					paintEnemyList(g);
				}
				if (m_enemyStatus == 1) {
					paintEnemySubMeun(g);
				}
				break;
			case UIWindowFactory.WINDOW_ID_DONGFU_GONGFA:
				title = "攻伐列表";
				UITools.paintBackGround(g, m_x, m_y, m_w, m_h, title);
				paintGongFaList(g);
				break;
		}
//		UITools.paintBackGround(g, m_x, m_y, m_w, m_h, title, butten, true, true);
//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH,
//				AbstractGameScreen.SCREEN_HEIGHT);
//		if (whileWindowID == UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY
//				&& m_enemyStatus == 1) {
//			if (m_enemy_subMenu_index == 3) {
//				paintSure(g, true, true);
//			}
//			else {
//				paintSure(g, false, false);
//			}
//			paintQuit(g, true, false);
//		}
//		else {
//			paintQuit(g, true, false);
//			paintSure(g, true, false);
//		}
		if (whileWindowID != UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY || m_enemyStatus != 1) {
			// 绘制翻页
			g.setClip(AbstractGameScreen.SCREEN_WIDTH / 2 - 10, LIST_FRAME_Y
					+ LIST_HELGHT, 20, 20);
			UITools.paintPage(g, m_x + (m_w >> 1), m_y + m_h - UITools.H_SOFTKEY - UITools.IW_WIN, currentPage,
					totalPage);
		}

	}

	/**
	 * 绘制攻伐列表
	 * @param g
	 */
	private void paintGongFaList(Graphics g)
	{
		// 绘制好友列表的标题
		paintTeamListTitle(g, "玩家姓名", "洞府", "阵营");
		// 绘制黑名单信息列表
		paintRectGongFaList(g);
	}

	/**
	 * 列表标题
	 * @param g
	 * @param str1
	 * 3个标题名字
	 * @param str2
	 * @param str3
	 * @param str4
	 */
	private void paintTeamListTitle(Graphics g, String str1, String str2,
			String str3)
	{
		UITools.drawListTitleItem(g, LISTNAME_NAME_X, LISTNAME_NAME_Y,
				LISTNAME_NAME_WIDTH3, LISTNAME_HEIGHT, str1);
		UITools.drawListTitleItem(g, LISTNAME_NAME_X + LISTNAME_NAME_WIDTH3
				+ LIST_SPACE, LISTNAME_NAME_Y, LISTNAME_OTHER_WIDTH3,
				LISTNAME_HEIGHT, str2);
		UITools.drawListTitleItem(g, LISTNAME_NAME_X + LISTNAME_NAME_WIDTH3
				+ LIST_SPACE * 2 + LISTNAME_OTHER_WIDTH3, LISTNAME_NAME_Y,
				LISTNAME_OTHER_WIDTH3, LISTNAME_HEIGHT, str3);

	}

	/**
	 * 绘制攻伐列表
	 * 
	 * @param g
	 */
	private void paintRectGongFaList(Graphics g)
	{
		drawGongFaFreamAndBG(g);
		Vector list = GameManager.getInstance().m_social_list;
		if (list == null || list.size() == 0) {
			return;
		}
		int GongFaListSize = list.size();
		for (int i = 0; i < GongFaListSize; i++) {
			SimpleRole memberRole = (SimpleRole) list.elementAt(i);
			if (i == memberIndex) {
				g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
				UITools.drawSelectBox(g, LIST_FRAME_X, LIST_FRAME_Y + LIST_RECT_H * i,
						LISTNAME_NAME_WIDTH3 + (LISTNAME_OTHER_WIDTH3 + LIST_SPACE) * 2, LIST_RECT_H);
			}
			drawRectDongFuListGongFaItem_H(g, UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS),
					memberRole, i);
		}
	}

	/***
	 * 绘制队员信息列表数据 行
	 * @param g
	 * "玩家姓名", "职业", "等级"
	 * @param x
	 * 宽中间的X
	 * @param y
	 * @param role
	 */
	private void drawRectDongFuListGongFaItem_H(Graphics g, int colour,
			SimpleRole role, int hint)
	{
		g.setClip(LIST_FRAME_X + 2, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				LISTNAME_NAME_WIDTH3 - 4, LIST_RECT_H);
		UITools.drawColorString(g, role.m_name, LIST_FRAME_X + (LISTNAME_NAME_WIDTH3 >> 1) + 2, LIST_FRAME_Y
				+ LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);
		g.setClip(LIST_FRAME_X + 2 + LISTNAME_NAME_WIDTH3 + LIST_SPACE, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				(LIST_SPACE + LISTNAME_OTHER_WIDTH3) * 2, LIST_RECT_H);
		UITools.drawColorString(g, role.m_jbp_grade + "级", LIST_FRAME_X
				+ LISTNAME_NAME_WIDTH3 + LIST_SPACE * 1
				+ (LISTNAME_OTHER_WIDTH3 >> 1), LIST_FRAME_Y + LIST_RECT_H
				* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);
		UITools.drawColorString(g, FACTION_WORD[role.m_faction]
				, LIST_FRAME_X + LISTNAME_NAME_WIDTH3 + LIST_SPACE * 2
						+ (LISTNAME_OTHER_WIDTH3 >> 1) + LISTNAME_OTHER_WIDTH3,
				LIST_FRAME_Y + LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
						| Graphics.HCENTER);
	}

	/**
	 * 绘制列表框和背景
	 * 
	 * @param g
	 */
	private void drawGongFaFreamAndBG(Graphics g)
	{
		UITools.drawListFrame(g, LIST_FRAME_X, LIST_FRAME_Y, LISTNAME_NAME_WIDTH3,
				LIST_HELGHT);
		UITools.drawListFrame(g, LIST_FRAME_X + LISTNAME_NAME_WIDTH3 + LIST_SPACE,
				LIST_FRAME_Y, LISTNAME_OTHER_WIDTH3, LIST_HELGHT);
		UITools.drawListFrame(g, LIST_FRAME_X + LISTNAME_NAME_WIDTH3 + LIST_SPACE
				* 2 + LISTNAME_OTHER_WIDTH3, LIST_FRAME_Y, LISTNAME_OTHER_WIDTH3,
				LIST_HELGHT);
	}

	/**
	 * 绘制发布通缉令 enemyStatus==2
	 * 
	 * @param g
	 */
	private void paintEnemySubMeun(Graphics g)
	{
		// 绘制标题
		UITools.drawTitle(g, "仇敌");
		g.setClip(m_background_fill_x, m_background_fill_y,
				m_background_fill_w, m_background_fill_h);
		UITools.drawListFrame(g, m_background_fill_x, m_background_fill_y,
				m_background_fill_w, m_background_fill_h);

		g.setColor(UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS));
		g.drawString(FABUTONGJI, AbstractGameScreen.SCREEN_WIDTH >> 1, m_background_fill_y + 6, Tools.HCENTER_TOP);
		g.setColor(UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS));
		g.drawString(FaBuTongJiLing[0], enemyStringOneLine_lable_x,
				enemyStringOneLine_y, Tools.LEFT_TOP);
		g.drawString(getIndexName(), enemyStringOneLine_contents_x,
				enemyStringOneLine_y, Tools.LEFT_TOP);
		SimpleRole role = (SimpleRole) GameManager.getInstance().m_social_list
				.elementAt(memberIndex);
		g.drawString(FaBuTongJiLing[1], enemyStringOneLine_lable_x,
				enemyStringOneLine_y + enemyStringNum, Tools.LEFT_TOP);
		if (role.m_grade > 0) {
			g.drawString("" + role.m_grade, enemyStringOneLine_contents_x,
					enemyStringOneLine_y + enemyStringNum, Tools.LEFT_TOP);
		}
		else {
			g.drawString("???", enemyStringOneLine_contents_x,
					enemyStringOneLine_y + enemyStringNum, Tools.LEFT_TOP);
		}
		g.drawString(FaBuTongJiLing[2], enemyStringOneLine_lable_x, enemyStringOneLine_y
				+ enemyStringNum * 2, Tools.LEFT_TOP);
		g.drawString("72小时", enemyStringOneLine_contents_x, enemyStringOneLine_y
				+ enemyStringNum * 2, Tools.LEFT_TOP);
		g.drawString(FaBuTongJiLing[3], enemyStringOneLine_lable_x, enemyStringOneLine_y
				+ enemyStringNum * 3, Tools.LEFT_TOP);
		g.drawString(FaBuTongJiLing[4], enemyStringOneLine_lable_x, enemyStringOneLine_y
				+ enemyStringNum * 5 - 10, Tools.LEFT_TOP);

		g.drawString(FaBuTongJiLing[5], enemyStringOneLine_lable_x, enemyStringOneLine_y
				+ enemyStringNum * 8 + 23, Tools.LEFT_TOP);
//		g.drawString("1", enemyStringOneLine_contents_x, enemyStringOneLine_y
//				+ enemyStringNum * 8 + 23, Tools.LEFT_TOP);
		g.drawString("%10 奖金金额", enemyStringOneLine_contents_x, enemyStringOneLine_y
				+ enemyStringNum * 8 + 23, Tools.LEFT_TOP);
//		if (m_enemy_moneystate==1) {

//		g.drawImage(UIManager.IMAGE_MONEY_GOLD, enemyStringOneLine_contents_x + 10, enemyStringOneLine_y
//					+ enemyStringNum * 8 + 3 + 23, Tools.LEFT_TOP);
//		}else {
//			g.drawImage(UIManager.IMAGE_YINPIAO, enemyStringOneLine_contents_x + 10, enemyStringOneLine_y
//					+ enemyStringNum * 8 + 3 + 23, Tools.LEFT_TOP);
//		}
		if (m_enemy_subMenu_index == 0) {
			UITools.paintInputRect(g, enemyMoneyAward_x, enemyMoneyAward_y, enemyMoneyAward_w, "" + m_enemy_jinbi_num,
					true);
		}
		else {
			UITools.paintInputRect(g, enemyMoneyAward_x, enemyMoneyAward_y, enemyMoneyAward_w, "" + m_enemy_jinbi_num,
					false);
		}
		g.drawImage(UIManager.IMAGE_MONEY_GOLD, enemyMoneyAward_x + enemyMoneyAward_w + 2, enemyMoneyAward_y + 6,
				Tools.LEFT_TOP);
//		if (m_enemy_subMenu_index == 1) {
//			UITools.paintInputRect(g, enemyMoneyAward_x, enemyMoneyAward_y + enemyMoneyAward_h + 4, enemyMoneyAward_w,
//					"" + m_enemy_yuanbao_num, true);
//		}
//		else {
//			UITools.paintInputRect(g, enemyMoneyAward_x, enemyMoneyAward_y + enemyMoneyAward_h + 4, enemyMoneyAward_w,
//					"" + m_enemy_yuanbao_num, false);
//		}
//		g.drawImage(UIManager.IMAGE_YINPIAO, enemyMoneyAward_x + enemyMoneyAward_w + 2, enemyMoneyAward_y
//				+ enemyMoneyAward_h + 4 + 3, Tools.LEFT_TOP);
//		g.drawImage(UIManager.IMAGE_MONEY_RMB, enemyMoneyAward_x + enemyMoneyAward_w + 2, enemyMoneyAward_y
//				+ enemyMoneyAward_h + 4 + 3, Tools.LEFT_TOP);
		if (m_enemy_subMenu_index == 1) {

			paintInputRectSocial(g, enemyStringMsg_x, enemyStringMsg_y - 5, enemyStringMsg_w, enemyStringMsg_h,
					m_enemy_msg, true);
		}
		else {
			paintInputRectSocial(g, enemyStringMsg_x, enemyStringMsg_y - 5, enemyStringMsg_w, enemyStringMsg_h,
					m_enemy_msg, false);
		}

	}

	private void paintEnemyList(Graphics g)
	{
		// 绘制标题
		UITools.drawTitle(g, "仇敌");
		// 绘制好友列表的标题
		paintTeamListTitle(g, "玩家姓名", "仇值", "等级", "洞府");
		// 绘制黑名单信息列表
		paintRectSocialList(g);
	}

	private void paintBliackList(Graphics g)
	{
		// 绘制标题
//		UITools.drawTitle(g, "黑名单");
		// 绘制好友列表的标题
		paintTeamListTitle(g, "玩家姓名", "等级", "职业", "种族");
		// 绘制黑名单信息列表
		paintRectSocialList(g);
//		int w = 80;
//		int h = UITools.H_LABEL;
//		int x = ((AbstractGameScreen.SCREEN_WIDTH - w) >> 1);
//		int y = QUIT_SURE_Y;
//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//		UITools.paintLabelStr(g, x, y, w, h, "1.加黑名单", true);
	}

	private void paintFriendList(Graphics g)
	{
		// 绘制标题
//		UITools.drawTitle(g, "好友");
		// 绘制好友列表的标题
		paintTeamListTitle(g, "玩家姓名", "等级", "职业", "洞府");
		// 绘制好友信息列表
		paintRectSocialList(g);
//		int w = 90;
//		int h = UITools.H_LABEL;
//		int x = ((AbstractGameScreen.SCREEN_WIDTH - w) >> 1);
//		int y = QUIT_SURE_Y;
//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//		UITools.paintLabelStr(g, x, y, w, h, "1.添加好友", true);
	}

	/**
	 * 绘制好友成员列表
	 * 
	 * @param g
	 */
	private void paintRectSocialList(Graphics g)
	{
		drawTeamFreamAndBG(g);
		Vector memberList = GameManager.getInstance().m_social_list;
		if (memberList == null || memberList.size() == 0) {
			return;
		}
		int listsize = memberList.size();
		for (int i = 0; i < listsize; i++) {
			SimpleRole memberRole = (SimpleRole) memberList.elementAt(i);
			if (i == memberIndex) {
				g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
				UITools.drawSelectBox(g, LIST_FRAME_X, LIST_FRAME_Y + LIST_RECT_H * (i),
						LISTNAME_NAME_WIDTH + (LISTNAME_OTHER_WIDTH + LIST_SPACE) * 3, LIST_RECT_H);
			}
			switch (whileWindowID) {
				case UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND: // 好友列表
					drawRectSocialFirendMSGItem_H(g, UIManager
							.getPaletteColor(UIPalette.COLOR_WORD_NOS),
							memberRole, i);
					break;
				case UIWindowFactory.WINDOW_ID_SOCIAL_BLACK: // 黑名单列表
					drawRectSocialBlackMSGItem_H(g, UIManager
							.getPaletteColor(UIPalette.COLOR_WORD_NOS),
							memberRole, i);
					break;
				case UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY: // 仇敌列表
					drawRectSocialEnemyMSGItem_H(g, UIManager
							.getPaletteColor(UIPalette.COLOR_WORD_NOS),
							memberRole, i);
			}
		}
	}

	/**
	 * 绘制列表框和背景
	 * 
	 * @param g
	 */
	private void drawTeamFreamAndBG(Graphics g)
	{
		drawRectTeamListBG(g, LIST_FRAME_X, LIST_FRAME_Y, LISTNAME_NAME_WIDTH,
				LIST_HELGHT);
		drawRectTeamListBG(g, LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE,
				LIST_FRAME_Y, LISTNAME_OTHER_WIDTH, LIST_HELGHT);
		drawRectTeamListBG(g, LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE
				* 2 + LISTNAME_OTHER_WIDTH, LIST_FRAME_Y, LISTNAME_OTHER_WIDTH,
				LIST_HELGHT);
		drawRectTeamListBG(g, LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE
				* 3 + LISTNAME_OTHER_WIDTH * 2, LIST_FRAME_Y,
				LISTNAME_OTHER_WIDTH, LIST_HELGHT);
	}

	/***
	 * 绘制队员信息列表数据 行
	 * 
	 * @param g
	 * "玩家姓名", "等级", "职业", "种族"
	 * @param x
	 * 宽中间的X
	 * @param y
	 * @param role
	 */
	private void drawRectSocialBlackMSGItem_H(Graphics g, int colour,
			SimpleRole role, int hint)
	{
		g.setClip(LIST_FRAME_X + 2, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				LISTNAME_NAME_WIDTH - 4, LIST_RECT_H);
		if (m_unitRollx != null && hint < (m_unitRollx.length - 1)) {
			UITools.drawColorString(g, role.m_name, LIST_FRAME_X
					- m_unitRollx[hint] + 2, LIST_FRAME_Y + LIST_RECT_H
					* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.LEFT);
		}
		else {
			UITools.drawColorString(g, role.m_name, LIST_FRAME_X
					+ 2, LIST_FRAME_Y + LIST_RECT_H
							* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.LEFT);
		}
		g.setClip(LIST_FRAME_X + 2 + LISTNAME_NAME_WIDTH + LIST_SPACE, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				(LIST_SPACE + LISTNAME_OTHER_WIDTH) * 3, LIST_RECT_H);
		if (role.m_online) {
			UITools.drawColorString(g, role.m_grade + "", LIST_FRAME_X
					+ LISTNAME_NAME_WIDTH + LIST_SPACE * 1 + (LISTNAME_OTHER_WIDTH >> 1), LIST_FRAME_Y
					+ LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);
			UITools.drawColorString(g,
					ActorRole.ROLE_VOCATION_LIST[role.m_vocation[role.m_vocation.length - 1]],
					LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE * 2
							+ (LISTNAME_OTHER_WIDTH >> 1)
							+ LISTNAME_OTHER_WIDTH, LIST_FRAME_Y
							+ LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
							| Graphics.HCENTER);
			UITools.drawColorString(g, ActorRole.ROLE_RACE_LIST[role.m_race],
					LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE * 3
							+ (LISTNAME_OTHER_WIDTH >> 1)
							+ LISTNAME_OTHER_WIDTH * 2, LIST_FRAME_Y
							+ LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
							| Graphics.HCENTER);
		}
		else {
			UITools.drawColorString(g, "--", LIST_FRAME_X + LISTNAME_NAME_WIDTH
					+ LIST_SPACE * 1 + (LISTNAME_OTHER_WIDTH >> 1),
					LIST_FRAME_Y + LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
							| Graphics.HCENTER);
			UITools.drawColorString(g, "--", LIST_FRAME_X + LISTNAME_NAME_WIDTH
					+ LIST_SPACE * 2 + (LISTNAME_OTHER_WIDTH >> 1)
					+ LISTNAME_OTHER_WIDTH, LIST_FRAME_Y + LIST_RECT_H
					* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);
			UITools.drawColorString(g, "--", LIST_FRAME_X + LISTNAME_NAME_WIDTH
					+ LIST_SPACE * 3 + (LISTNAME_OTHER_WIDTH >> 1)
					+ LISTNAME_OTHER_WIDTH * 2, LIST_FRAME_Y + LIST_RECT_H
					* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);
		}
	}

	/***
	 * 绘制队员信息列表数据 行
	 * 
	 * @param g
	 * "玩家姓名", "等级", "职业", "洞府"
	 * @param x
	 * 宽中间的X
	 * @param y
	 * @param role
	 */
	private void drawRectSocialFirendMSGItem_H(Graphics g, int colour,
			SimpleRole role, int hint)
	{
		g.setClip(LIST_FRAME_X + 2, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				LISTNAME_NAME_WIDTH - 4, LIST_RECT_H);
		if (m_unitRollx != null && hint < (m_unitRollx.length - 1)) {

			UITools.drawColorString(g, role.m_name, LIST_FRAME_X
					- m_unitRollx[hint] + 2, LIST_FRAME_Y + LIST_RECT_H
					* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.LEFT);
		}
		else {
			UITools.drawColorString(g, role.m_name, LIST_FRAME_X
					+ 2, LIST_FRAME_Y + LIST_RECT_H
							* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.LEFT);
		}
		g.setClip(LIST_FRAME_X + 2 + LISTNAME_NAME_WIDTH + LIST_SPACE, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				(LIST_SPACE + LISTNAME_OTHER_WIDTH) * 3, LIST_RECT_H);
		if (role.m_online) {
			UITools.drawColorString(g, role.m_grade + "", LIST_FRAME_X
					+ LISTNAME_NAME_WIDTH + LIST_SPACE * 1
					+ (LISTNAME_OTHER_WIDTH >> 1), LIST_FRAME_Y
					+ LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
					| Graphics.HCENTER);
			UITools.drawColorString(g,
					ActorRole.ROLE_VOCATION_LIST[role.m_vocation[role.m_vocation.length - 1]],
					LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE * 2
							+ (LISTNAME_OTHER_WIDTH >> 1)
							+ LISTNAME_OTHER_WIDTH, LIST_FRAME_Y
							+ LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
							| Graphics.HCENTER);
		}
		else {
			UITools.drawColorString(g, "--", LIST_FRAME_X + LISTNAME_NAME_WIDTH
					+ LIST_SPACE * 1 + (LISTNAME_OTHER_WIDTH >> 1),
					LIST_FRAME_Y + 5 + LIST_RECT_H * hint, colour, Graphics.TOP
							| Graphics.HCENTER);
			UITools.drawColorString(g, "--", LIST_FRAME_X + LISTNAME_NAME_WIDTH
					+ LIST_SPACE * 2 + (LISTNAME_OTHER_WIDTH >> 1)
					+ LISTNAME_OTHER_WIDTH, LIST_FRAME_Y + LIST_RECT_H
					* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);

		}
		if (role.m_isWatering == 0) {
			g.drawImage(img_dongfu_watering, LIST_FRAME_X
					+ LISTNAME_NAME_WIDTH + LIST_SPACE * 3
					+ LISTNAME_OTHER_WIDTH * 2 + (LISTNAME_OTHER_WIDTH >> 1), LIST_FRAME_Y
					+ LIST_RECT_H * hint + 3, Tools.HCENTER_TOP);
		}
//		if (role.m_isGongFa == 0) {
//		g.drawImage(img_dongfu_war, LIST_FRAME_X + LISTNAME_NAME_WIDTH
//				+ LIST_SPACE * 3 + (LISTNAME_OTHER_WIDTH >> 1)
//				+ LISTNAME_OTHER_WIDTH * 2, LIST_FRAME_Y
//				+ LIST_RECT_H * hint + STRING_LIST_Y, Tools.LEFT_TOP);
//	}
	}

	/***
	 * 绘制队员信息列表数据 行
	 * 
	 * @param g
	 * "玩家姓名", "仇恨度", "是否锁定", "等级"
	 * @param x
	 * 宽中间的X
	 * @param y
	 * @param role
	 */
	private void drawRectSocialEnemyMSGItem_H(Graphics g, int colour,
			SimpleRole role, int hint)
	{
		g.setClip(LIST_FRAME_X + 2, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				LISTNAME_NAME_WIDTH - 4, LIST_RECT_H);
		UITools.drawColorString(g, role.m_name, LIST_FRAME_X
				- m_unitRollx[hint] + 2, LIST_FRAME_Y + LIST_RECT_H
				* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.LEFT);
		if (role.m_is_Locked) {
			g.drawImage(UIManager.IMAGE_ACTORITEM_LOCK, LIST_FRAME_X + LISTNAME_NAME_WIDTH - 2, LIST_FRAME_Y
					+ LIST_RECT_H
					* hint + 2, Graphics.TOP | Graphics.RIGHT);

		}
		g.setClip(LIST_FRAME_X + 2 + LISTNAME_NAME_WIDTH + LIST_SPACE, LIST_FRAME_Y + 2 + LIST_RECT_H * hint,
				(LIST_SPACE + LISTNAME_OTHER_WIDTH) * 3, LIST_RECT_H);

		UITools.drawColorString(g, role.m_HatredDegrees, LIST_FRAME_X
				+ LISTNAME_NAME_WIDTH + LIST_SPACE * 1
				+ (LISTNAME_OTHER_WIDTH >> 1), LIST_FRAME_Y + LIST_RECT_H
				* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);

		if (role.m_online) {

			UITools.drawColorString(g, "" + role.m_grade, LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE * 2
					+ (LISTNAME_OTHER_WIDTH >> 1) + LISTNAME_OTHER_WIDTH,
					LIST_FRAME_Y + LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
							| Graphics.HCENTER);
		}
		else {
			UITools.drawColorString(g, "--", LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE * 2
					+ (LISTNAME_OTHER_WIDTH >> 1) + LISTNAME_OTHER_WIDTH,
					LIST_FRAME_Y + LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
							| Graphics.HCENTER);
		}
		if (role.m_isGongFa == 1) {
			g.drawImage(img_dongfu_war, LIST_FRAME_X + LISTNAME_NAME_WIDTH
					+ LIST_SPACE * 3 + (LISTNAME_OTHER_WIDTH >> 1)
					+ LISTNAME_OTHER_WIDTH * 2, LIST_FRAME_Y
					+ LIST_RECT_H * hint + 4, Graphics.TOP | Graphics.HCENTER);
		}
//		UITools.drawColorString(g, role.m_is_Locked == true ? isLockTrue
//				: isLockFalse, LIST_FRAME_X + LISTNAME_NAME_WIDTH + LIST_SPACE * 2
//				+ (LISTNAME_OTHER_WIDTH >> 1) + LISTNAME_OTHER_WIDTH,
//				LIST_FRAME_Y + LIST_RECT_H * hint + STRING_LIST_Y, colour, Graphics.TOP
//				| Graphics.HCENTER);
//		UITools.drawColorString(g, "--", LIST_FRAME_X + LISTNAME_NAME_WIDTH
//				+ LIST_SPACE * 3 + (LISTNAME_OTHER_WIDTH >> 1)
//				+ LISTNAME_OTHER_WIDTH * 2, LIST_FRAME_Y + LIST_RECT_H
//				* hint + STRING_LIST_Y, colour, Graphics.TOP | Graphics.HCENTER);
	}

	/**
	 * 绘制队员信息列表 一列
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param data
	 * @param type
	 */
	private void drawRectTeamListBG(Graphics g, int x, int y, int w, int h)
	{
//		g.setClip(x, y, w, h);
//		for (int i = 0; i < LIST_HELGHT / LIST_RECT_H + 1; i++) {
//			if (i % 2 == 0) {
//				g.setColor(UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
//				g.fillRect(x + 2, y + 2 + LIST_RECT_H * i, w - 3, LIST_RECT_H);
//			}
//			else {
//				g.setColor(UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
//				g.fillRect(x + 2, y + 2 + LIST_RECT_H * i, w - 3, LIST_RECT_H);
//			}
//		}
		UITools.drawListFrame(g, x, y, w, h);
	}

	/**
	 * 列表标题
	 * 
	 * @param g
	 * @param str1
	 * 四个标题名字
	 * @param str2
	 * @param str3
	 * @param str4
	 */
	private void paintTeamListTitle(Graphics g, String str1, String str2,
			String str3, String str4)
	{
		UITools.drawListTitleItem(g, LISTNAME_NAME_X, LISTNAME_NAME_Y,
				LISTNAME_NAME_WIDTH, LISTNAME_HEIGHT, str1);
		UITools.drawListTitleItem(g, LISTNAME_NAME_X + LISTNAME_NAME_WIDTH
				+ LIST_SPACE, LISTNAME_NAME_Y, LISTNAME_OTHER_WIDTH,
				LISTNAME_HEIGHT, str2);
		UITools.drawListTitleItem(g, LISTNAME_NAME_X + LISTNAME_NAME_WIDTH
				+ LIST_SPACE * 2 + LISTNAME_OTHER_WIDTH, LISTNAME_NAME_Y,
				LISTNAME_OTHER_WIDTH, LISTNAME_HEIGHT, str3);
		UITools.drawListTitleItem(g, LISTNAME_NAME_X + LISTNAME_NAME_WIDTH
				+ LIST_SPACE * 3 + LISTNAME_OTHER_WIDTH * 2, LISTNAME_NAME_Y,
				LISTNAME_OTHER_WIDTH, LISTNAME_HEIGHT, str4);

	}

	private void initImage()
	{
		img_dongfu_watering = UIManager.getInstance().coinImage(
				UIManager.RES_DONGFU_WATERING);
		img_dongfu_war = UIManager.getInstance().coinImage(
				UIManager.RES_DONGFU_WAR);
	}

	private boolean flag = false;

	protected void keyLogic()
	{
		m_currframeCount++;
		if (whileWindowID == UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND) {
			if (whileLogic == 0) {
				if (flag) {
					unitRollx();
				}
				logicFriend();
			}
			else if (whileLogic == 1) {
				if (flag) {
					unitRollx();
				}
				logicFirendMail();
			}
		}
		else if (whileWindowID == UIWindowFactory.WINDOW_ID_SOCIAL_BLACK) {
			if (whileLogic == 0) {
				if (flag) {
					unitRollx();
				}
				logicBlack();
			}
			else if (whileLogic == 1) {
				if (flag) {
					unitRollx();
				}
				logicBlackMail();
			}
		}
		else if (whileWindowID == UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY) {
			if (whileLogic == 0) {
				if (m_enemyStatus == 0) {
					if (flag) {
						unitRollx();
					}
					logicEnemy();
				}
				else if (m_enemyStatus == 1) {
					logicEnemySubMenu();
				}
			}
			else if (whileLogic == 1) {
				if (flag) {
					unitRollx();
				}
				logicEnemyMail();
			}

		}
		else if (whileWindowID == UIWindowFactory.WINDOW_ID_DONGFU_GONGFA) {
			logicGongFa();
		}
	}

	private void logicGongFa()
	{

		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			Tools.debugPrintln("社交好友监听>>>>>>>>");
			if (GameManager.getInstance().m_social_list == null
					|| GameManager.getInstance().m_social_list.size() == 0
					|| memberIndex < 0) {
				return;
			}
			String[] memberItems = new String[] { "攻伐洞府" };
			final UIPopmenu win = (UIPopmenu) UIManager.getInstance()
					.createWindow(UIWindowFactory.WINDOW_POPMENU);
			win.setPopmenus(memberItems);
			win.addListener(new UIListener() {

				public void actionPerformed()
						{
							if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
												|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
								GameManager.getInstance().m_game_message.sendDongFuGongFa(getIndexID(),
													getIndexName());
								UIManager.getInstance().removeWindow(win);
							}
							else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
								UIManager.getInstance().removeWindow(win);
							}
						}
			});
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex > 0) {
					memberIndex--;
				}
				else if (currentPage > 0) {
					GameManager.getInstance().m_game_message.sendDongFuGongFaList(currentPage - 1, memberPageNum);
					memberIndex = memberPageNum - 1;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex < (GameManager.getInstance().m_social_list.size() - 1)) { // 不等于成员数
					memberIndex++;
				}
				else if (currentPage < totalPage - 1) {
					GameManager.getInstance().m_game_message.sendDongFuGongFaList(currentPage + 1, memberPageNum);
					memberIndex = 0;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (currentPage > 0) {
				GameManager.getInstance().m_game_message.sendDongFuGongFaList(currentPage - 1, memberPageNum);
				memberIndex = 0;
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (currentPage < totalPage - 1) {
				GameManager.getInstance().m_game_message.sendDongFuGongFaList(currentPage + 1, memberPageNum);
				memberIndex = 0;
			}
		}

	}

	private int m_enemy_subMenu_index = 0;
	private int m_enemy_jinbi_num;
	private int m_enemy_yuanbao_num;
	private String m_enemy_msg[];
	private byte m_enemy_moneystate;

	/**
	 * 发布通缉领界面
	 */
	private void logicEnemySubMenu()
	{
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (m_enemy_subMenu_index == 0) {
//				m_enemy_yuanbao_num = 0;
				m_enemy_moneystate = 0;
				gotoWantedwrite();
			}
			else if (m_enemy_subMenu_index == 1) {
				gotoWantedwrite();
			}
//			else if (m_enemy_subMenu_index == 1) {
//				m_enemy_jinbi_num = 0;
//				m_enemy_moneystate = 1;
//				gotoWantedwrite();
//			}
//			else if (m_enemy_subMenu_index == 2) {
//				gotoWantedwrite();
//			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
			if ((m_enemy_jinbi_num != 0 || m_enemy_yuanbao_num != 0) && m_enemy_msg != null) {
				final UIMessageBox msgwin = (UIMessageBox) UIManager.getInstance()
						.createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
				msgwin.setMessage("发布通缉令", "同意", "不同意", "是否确认发布");
				msgwin.addListener(new UIListener() {
					public void actionPerformed()
						{
							if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
														|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
								String msg = "";
								for (int i = 0; i < m_enemy_msg.length; i++) {
									msg = msg + m_enemy_msg[i];
								}
								GameManager.getInstance().m_game_message.sendEnemyWanted(
															getIndexID(), getIndexName(), m_enemy_moneystate,
																m_enemy_jinbi_num * 10000, msg);
								m_enemy_subMenu_index = 0;
								m_enemyStatus = 0;
								UIManager.getInstance().removeWindow(msgwin);
							}
							else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
								UIManager.getInstance().removeWindow(msgwin);

							}
						}
				});

			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			m_enemyStatus = 0;
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (m_enemy_subMenu_index > 0) {
				m_enemy_subMenu_index--;
			}
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (m_enemy_subMenu_index < 1) {
				m_enemy_subMenu_index++;
			}
		}

	}

	private void logicEnemyMail()
	{

		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			Tools.debugPrintln("写信社交监听>>>>>>>>");
			if (GameManager.getInstance().m_social_list == null
					|| GameManager.getInstance().m_social_list.size() == 0
					|| memberIndex < 0) {
				return;
			}
			getLogicSocialToMail();
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
			// UiManager.getInstance().loadWindow(UiManager.ID_WINDOW_MAINUI);
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex > 0) {
					memberIndex--;
				}
				else if (currentPage > 0) {
					GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage - 1),
							(short) memberPageNum);
					memberIndex = memberPageNum - 1;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex < (GameManager.getInstance().m_social_list.size() - 1)) { // 不等于成员数
					memberIndex++;
				}
				else if (currentPage < totalPage - 1) {
					GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage + 1),
							(short) memberPageNum);
					memberIndex = 0;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (currentPage > 0) {
				GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage - 1),
						(short) memberPageNum);
				memberIndex = 0;
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (currentPage < (totalPage - 1)) {
				GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage + 1),
						(short) memberPageNum);
				memberIndex = 0;
			}
		}

	}

	private void logicEnemy()
	{

		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			Tools.debugPrintln("社交监听>>>>>>>>");
			if (GameManager.getInstance().m_social_list == null
					|| GameManager.getInstance().m_social_list.size() == 0
					|| memberIndex < 0) {
				return;
			}
			String[] items2 = null;
			if (getIndexIsWar()) {
				items2 = new String[] { "1.查看", "2.查询位置", "3.传送", "4.锁定仇敌", "5.删除仇敌",
						"6.发布通缉令", "7.攻伐洞府", "0.返回" };
				UIPopmenu win = (UIPopmenu) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_POPMENU);
				win.setPopmenus(items2);
				win.addListener(getEnemylistSubmenuListener2(win));
			}
			else {

				items2 = new String[] { "1.查看", "2.查询位置", "3.传送", "4.锁定仇敌", "5.删除仇敌",
						"6.发布通缉令", "0.返回" };
				UIPopmenu win = (UIPopmenu) UIManager.getInstance().createWindow(
						UIWindowFactory.WINDOW_POPMENU);
				win.setPopmenus(items2);
				win.addListener(getEnemylistSubmenuListener(win));
			}

		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
			// UiManager.getInstance().loadWindow(UiManager.ID_WINDOW_MAINUI);
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex > 0) {
					memberIndex--;
				}
				else if (currentPage > 0) {
					GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage - 1),
							(short) memberPageNum);
					memberIndex = memberPageNum - 1;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex < (GameManager.getInstance().m_social_list.size() - 1)) { // 不等于成员数
					memberIndex++;
				}
				else if (currentPage < totalPage - 1) {
					GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage + 1),
							(short) memberPageNum);
					memberIndex = 0;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (currentPage > 0) {
				GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage - 1),
						(short) memberPageNum);
				memberIndex = 0;
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (currentPage < (totalPage - 1)) {
				GameManager.getInstance().m_game_message.sendEnemyList((short) (currentPage + 1),
						(short) memberPageNum);
				memberIndex = 0;
			}
		}
	}

	private void logicFirendMail()
	{
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			Tools.debugPrintln("写信社交监听>>>>>>>>");
			if (GameManager.getInstance().m_social_list == null
					|| GameManager.getInstance().m_social_list.size() == 0
					|| memberIndex < 0) {
				return;
			}
			getLogicSocialToMail();
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex > 0) {
					memberIndex--;
				}
				else if (currentPage > 0) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_FRIEND, currentPage - 1, memberPageNum);
					memberIndex = memberPageNum - 1;
				}
			}
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex < (GameManager.getInstance().m_social_list.size() - 1)) { // 不等于成员数
					memberIndex++;
				}
				else if (currentPage < totalPage - 1) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_FRIEND, currentPage + 1, memberPageNum);
					memberIndex = 0;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
			gotoFriendWriteContentFrom();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (currentPage > 0) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_FRIEND, currentPage - 1, memberPageNum);
				memberIndex = 0;
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (currentPage < totalPage - 1) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_FRIEND, currentPage + 1, memberPageNum);
				memberIndex = 0;
			}
		}
	}

	private void logicFriend()
	{
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			Tools.debugPrintln("社交好友监听>>>>>>>>");
			if (GameManager.getInstance().m_social_list == null
					|| GameManager.getInstance().m_social_list.size() == 0
					|| memberIndex < 0) {
				return;
			}
			String[] memberItems = null;
//			if (getIndexIsWatering() == 0 && getIndexIsWar() == 0) {
//				memberItems = new String[] { "1.查看", "2.传音入密", "3.交易", "4.飞鸽传书",
//						"5.邀请组队", "6.删除好友", "7.浇水", "8.攻打洞府", "0.返回" };
//				UIPopmenu win = (UIPopmenu) UIManager.getInstance()
//						.createWindow(UIWindowFactory.WINDOW_POPMENU);
//				win.setPopmenus(memberItems);
//				win.addListener(getFriendListSubmenuListener4(win));
//			}
//			else if (getIndexIsWar() == 0) {
//				memberItems = new String[] { "1.查看", "2.传音入密", "3.交易", "4.飞鸽传书",
//						"5.邀请组队", "6.删除好友", "7.攻打洞府", "0.返回" };
//				UIPopmenu win = (UIPopmenu) UIManager.getInstance()
//						.createWindow(UIWindowFactory.WINDOW_POPMENU);
//				win.setPopmenus(memberItems);
//				win.addListener(getFriendListSubmenuListener3(win));
//			}
			if (getIndexIsWatering() == 0) {
				memberItems = new String[] { "1.查看", "2.传音入密", "3.交易", "4.飞鸽传书",
						"5.邀请组队", "6.删除好友", "7.浇水", "0.返回" };
				UIPopmenu win = (UIPopmenu) UIManager.getInstance()
						.createWindow(UIWindowFactory.WINDOW_POPMENU);
				win.setPopmenus(memberItems);
				win.addListener(getFriendListSubmenuListener2(win));
			}
			else {

				memberItems = new String[] { "1.查看", "2.传音入密", "3.交易", "4.飞鸽传书",
						"5.邀请组队", "6.删除好友", "0.返回" };
				UIPopmenu win = (UIPopmenu) UIManager.getInstance()
						.createWindow(UIWindowFactory.WINDOW_POPMENU);
				win.setPopmenus(memberItems);
				win.addListener(getFriendListSubmenuListener(win));
			}
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex > 0) {
					memberIndex--;
				}
				else if (currentPage > 0) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_FRIEND, currentPage - 1, memberPageNum);
					memberIndex = memberPageNum - 1;
				}
			}
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex < (GameManager.getInstance().m_social_list.size() - 1)) { // 不等于成员数
					memberIndex++;
				}
				else if (currentPage < totalPage - 1) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_FRIEND, currentPage + 1, memberPageNum);
					memberIndex = 0;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
			gotoFriendWriteContentFrom();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (currentPage > 0) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_FRIEND, currentPage - 1, memberPageNum);
				memberIndex = 0;
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (currentPage < totalPage - 1) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_FRIEND, currentPage + 1, memberPageNum);
				memberIndex = 0;
			}
		}
	}

	private void logicBlackMail()
	{

		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			Tools.debugPrintln("写信社交监听>>>>>>>>");
			if (GameManager.getInstance().m_social_list == null
					|| GameManager.getInstance().m_social_list.size() == 0
					|| memberIndex < 0) {
				return;
			}
			getLogicSocialToMail();
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex > 0) {
					memberIndex--;
				}
				else if (currentPage > 0) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_BLACKLIST, currentPage - 1, memberPageNum);
					memberIndex = memberPageNum - 1;
				}
			}
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex < (GameManager.getInstance().m_social_list.size() - 1)) { // 不等于成员数
					memberIndex++;
				}
				else if (currentPage < totalPage - 1) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_BLACKLIST, currentPage + 1, memberPageNum);
					memberIndex = 0;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
			gotoBlacekWriteContentFrom();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (currentPage > 0) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_BLACKLIST, currentPage - 1, memberPageNum);
				memberIndex = 0;
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (currentPage < totalPage - 1) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_BLACKLIST, currentPage + 1, memberPageNum);
				memberIndex = 0;
			}
		}

	}

	private void logicBlack()
	{

		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			Tools.debugPrintln("社交监听>>>>>>>>");
			if (GameManager.getInstance().m_social_list == null
					|| GameManager.getInstance().m_social_list.size() == 0
					|| memberIndex < 0) {
				return;
			}
			String[] items1 = { "1.查看", "2.解除屏蔽", "0.返回" };
			UIPopmenu win = (UIPopmenu) UIManager.getInstance().createWindow(
					UIWindowFactory.WINDOW_POPMENU);
			win.setPopmenus(items1);
			win.addListener(getBlacklistSubmenuListener(win));
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex > 0) {
					memberIndex--;
				}
				else if (currentPage > 0) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_BLACKLIST, currentPage - 1, memberPageNum);
					memberIndex = memberPageNum - 1;
				}
			}
		}
		else if (AbstractGameScreen
				.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (GameManager.getInstance().m_social_list != null) {
				if (memberIndex < (GameManager.getInstance().m_social_list.size() - 1)) { // 不等于成员数
					memberIndex++;
				}
				else if (currentPage < totalPage - 1) {
					GameManager.getInstance().m_game_message.sendSocialList(
							GameManager.SOCIAL_TYPE_BLACKLIST, currentPage + 1, memberPageNum);
					memberIndex = 0;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
			gotoBlacekWriteContentFrom();
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (currentPage > 0) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_BLACKLIST, currentPage - 1, memberPageNum);
				memberIndex = 0;
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (currentPage < totalPage - 1) {
				GameManager.getInstance().m_game_message.sendSocialList(
						GameManager.SOCIAL_TYPE_BLACKLIST, currentPage + 1, memberPageNum);
				memberIndex = 0;
			}
		}

	}

	/**
	 * 好友界面监听
	 * 
	 * @param win
	 * @return
	 */
	private UIListener getFriendListSubmenuListener(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
					seeRole();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
					writeMsg();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
					Deal();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
					writeMail();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {// 组队申请
					GameManager.getInstance().m_game_message
							.sendTeamRequest(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY6)) {
					GameManager.getInstance().m_game_message.sendSocialDelete(
							GameManager.SOCIAL_TYPE_FRIEND, getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0: // 查看
							seeRole();
							break;
						case 1: // 密语
							writeMsg();
							break;
						case 2: // 交易
							Deal();
							break;
						case 3: // 发邮件
							writeMail();
							break;
						case 4: // 组队申请
							GameManager.getInstance().m_game_message
									.sendTeamRequest(getIndexID());
							break;
						case 5: // 删除好友
							GameManager.getInstance().m_game_message
									.sendSocialDelete(
											GameManager.SOCIAL_TYPE_FRIEND,
											getIndexID());
							break;
						case 6: // 返回
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_KEY0)) {
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	/**
	 * 好友界面监听2洞府要浇水
	 * 
	 * @param win
	 * @return
	 */
	private UIListener getFriendListSubmenuListener2(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
					seeRole();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
					writeMsg();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
					Deal();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
					writeMail();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {// 组队申请
					GameManager.getInstance().m_game_message
							.sendTeamRequest(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY6)) {
					GameManager.getInstance().m_game_message.sendSocialDelete(
							GameManager.SOCIAL_TYPE_FRIEND, getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY7)) {
//					UICaveWorldWindow caveWin = (UICaveWorldWindow) UIManager.getInstance().getWindowById(
//							UIWindowFactory.WINDOW_ID_DONGFU);
//					if (caveWin != null) {
					GameManager.getInstance().m_game_message.sendwatering((byte) 2, getIndexID());
//					caveWin.m_dongfu_is_jiaoguang = 0;
//					}
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0: // 查看
							seeRole();
							break;
						case 1: // 密语
							writeMsg();
							break;
						case 2: // 交易
							Deal();
							break;
						case 3: // 发邮件
							writeMail();
							break;
						case 4: // 组队申请
							GameManager.getInstance().m_game_message.sendTeamRequest(getIndexID());
							break;
						case 5: // 删除好友
							GameManager.getInstance().m_game_message
									.sendSocialDelete(GameManager.SOCIAL_TYPE_FRIEND, getIndexID());
							break;
						case 6: // 浇水
							GameManager.getInstance().m_game_message.sendwatering((byte) 2, getIndexID());
							break;
						case 7: // 返回
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY0)) {
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	/**
	 * 好友界面监听3洞府攻伐
	 * 
	 * @param win
	 * @return
	 */
	private UIListener getFriendListSubmenuListener3(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
					seeRole();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
					writeMsg();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
					Deal();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
					writeMail();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {// 组队申请
					GameManager.getInstance().m_game_message
							.sendTeamRequest(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY6)) {
					GameManager.getInstance().m_game_message.sendSocialDelete(
							GameManager.SOCIAL_TYPE_FRIEND, getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY7)) {
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0: // 查看
							seeRole();
							break;
						case 1: // 密语
							writeMsg();
							break;
						case 2: // 交易
							Deal();
							break;
						case 3: // 发邮件
							writeMail();
							break;
						case 4: // 组队申请
							GameManager.getInstance().m_game_message
									.sendTeamRequest(getIndexID());
							break;
						case 5: // 删除好友
							GameManager.getInstance().m_game_message
									.sendSocialDelete(
											GameManager.SOCIAL_TYPE_FRIEND,
											getIndexID());
							break;
						case 6: // 攻打洞府
							break;
						case 7: // 返回
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_KEY0)) {
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	/**
	 * 好友界面监听2洞府要浇水与攻伐
	 * 
	 * @param win
	 * @return
	 */
	private UIListener getFriendListSubmenuListener4(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
					seeRole();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
					writeMsg();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
					Deal();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
					writeMail();
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {// 组队申请
					GameManager.getInstance().m_game_message
							.sendTeamRequest(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY6)) {
					GameManager.getInstance().m_game_message.sendSocialDelete(
							GameManager.SOCIAL_TYPE_FRIEND, getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY7)) {
					GameManager.getInstance().m_game_message.sendwatering((byte) 2, getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY8)) {
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0: // 查看
							seeRole();
							break;
						case 1: // 密语
							writeMsg();
							break;
						case 2: // 交易
							Deal();
							break;
						case 3: // 发邮件
							writeMail();
							break;
						case 4: // 组队申请
							GameManager.getInstance().m_game_message.sendTeamRequest(getIndexID());
							break;
						case 5: // 删除好友
							GameManager.getInstance().m_game_message.sendSocialDelete(GameManager.SOCIAL_TYPE_FRIEND,
									getIndexID());
							break;
						case 6: // 前往洞府
							GameManager.getInstance().m_game_message.sendwatering((byte) 2, getIndexID());
							break;
						case 7: // 攻打洞府
							break;
						case 8:// 放回
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_KEY0)) {
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	/**
	 * 黑名单子界面监听
	 * 
	 * @param win
	 * @return
	 */
	private UIListener getBlacklistSubmenuListener(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
					seeRole();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
					GameManager.getInstance().m_game_message.sendSocialDelete(
							GameManager.SOCIAL_TYPE_BLACKLIST, getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_A)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0:// 查看
							seeRole();
							break;
						case 1:// 解除屏蔽
							GameManager.getInstance().m_game_message
									.sendSocialDelete(
											GameManager.SOCIAL_TYPE_BLACKLIST,
											getIndexID());
							break;
						case 2:// 返回
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	/**
	 * 仇敌子界面监听
	 * 
	 * @param win
	 * @return
	 */
	public UIListener getEnemylistSubmenuListener(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {// 查看
					seeRole();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY2)) { // 查询位置
					GameManager.getInstance().m_game_message.sendEnemyPosition(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {// 传送
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "此功能占未开放");
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {// 锁定仇敌
					GameManager.getInstance().m_game_message.sendEnemyLock(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {// 删除
					GameManager.getInstance().m_game_message.sendEnemyDelete(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY6)) { // 发布通缉令
					m_enemyStatus = 1;
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) { // 返回
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen
								.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0: // 查看
							seeRole();
							break;
						case 1: // 查询位置
							GameManager.getInstance().m_game_message
									.sendEnemyPosition(getIndexID());
							break;
						case 2: // 传送
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "此功能占未开放");
							break;
						case 3: // 锁定仇敌
							GameManager.getInstance().m_game_message
									.sendEnemyLock(getIndexID());
							break;
						case 4: // 删除
							GameManager.getInstance().m_game_message
									.sendEnemyDelete(getIndexID());
							break;
						case 5: // 发布通缉令
							m_enemyStatus = 1;
							break;
						case 6: // 返回
							UIManager.getInstance().removeWindow(win);
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	/**
	 * 仇敌子界面监听
	 * 
	 * @param win
	 * @return
	 */
	public UIListener getEnemylistSubmenuListener2(final UIPopmenu win)
	{
		return new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {// 查看
					seeRole();
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY2)) { // 查询位置
					GameManager.getInstance().m_game_message
							.sendEnemyPosition(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {// 传送
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "此功能占未开放");
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {// 锁定仇敌
					GameManager.getInstance().m_game_message
							.sendEnemyLock(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {// 删除
					GameManager.getInstance().m_game_message
							.sendEnemyDelete(getIndexID());
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen
						.haveKeyPressed(AbstractGameScreen.GK_KEY6)) { // 发布通缉令
					m_enemyStatus = 1;
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY7)) { // 攻伐洞府
					if (m_dongfu_GongFa_surplus > 0) {
						long nowtime = System.currentTimeMillis();
						if (nowtime >= (m_dongfu_nextTime_Gongfa)) {
							GameManager.getInstance().m_game_message.sendDongFuGongFa(getIndexID(), getIndexName());
						}
						else {
							//冷却时间未到
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "攻伐冷却时间还剩："
									+ ((nowtime - (m_dongfu_nextTime_Gongfa)) / 60 + 1) + "分钟");
						}
					}
					else {
						//剩余次数不足
						GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "您的攻伐剩余次数为0");
					}
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY0)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) { // 返回
					UIManager.getInstance().removeWindow(win);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = win.getCurrentIndex();
					switch (index) {
						case 0: // 查看
							seeRole();
							break;
						case 1: // 查询位置
							GameManager.getInstance().m_game_message
									.sendEnemyPosition(getIndexID());
							break;
						case 2: // 传送
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "此功能占未开放");
							break;
						case 3: // 锁定仇敌
							GameManager.getInstance().m_game_message
									.sendEnemyLock(getIndexID());
							break;
						case 4: // 删除
							GameManager.getInstance().m_game_message
									.sendEnemyDelete(getIndexID());
							break;
						case 5: // 发布通缉令
							m_enemyStatus = 1;
							break;
						case 6: //攻伐洞府

							if (m_dongfu_GongFa_surplus > 0) {
								long nowtime = System.currentTimeMillis();
								if (nowtime >= m_dongfu_nextTime_Gongfa) {
									GameManager.getInstance().m_game_message.sendDongFuGongFa(getIndexID(),
											getIndexName());
								}
								else {
									//冷却时间未到
									GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "攻伐冷却时间还剩："
											+ ((nowtime - (m_dongfu_nextTime_Gongfa)) / 60 + 1) + "分钟");
								}
							}
							else {
								//剩余次数不足
								GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "您的攻伐剩余次数为0");
							}
							break;
						case 7: // 返回
							UIManager.getInstance().removeWindow(win);
							break;
					}
					UIManager.getInstance().removeWindow(win);
				}
			}
		};
	}

	private int currentPage = 0; // 当前页
	private int totalPage = 1; // 总页数

	/**
	 * 读取社交界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialList(DataInputStream dis) throws IOException
	{
		GameManager.getInstance().m_game_message.unlockNetwork();
		short state = dis.readShort();
		String msg = dis.readUTF();
		Tools.debugPrintln("social list state = " + state);
		if (state == 1) {
			GameManager.getInstance().m_social_list.removeAllElements();

			byte listType = dis.readByte();// 类型
			Tools.debugPrintln("type = " + listType);
			UISocialWindow window = null;
			switch (listType) {
				case GameManager.SOCIAL_TYPE_FRIEND:
					window = (UISocialWindow) UIManager.getInstance()
							.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
					if (window == null) {
						window = (UISocialWindow) UIManager.getInstance()
								.createWindow(
										UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
					}
					break;
				case GameManager.SOCIAL_TYPE_BLACKLIST:
					window = (UISocialWindow) UIManager.getInstance()
							.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_BLACK);
					if (window == null) {
						window = (UISocialWindow) UIManager.getInstance()
								.createWindow(UIWindowFactory.WINDOW_ID_SOCIAL_BLACK);
					}
					break;
			}
			window.flag = false;
			synchronized (window) {
				window.currentPage = dis.readInt();
				Tools.debugPrintln("currentPage = " + window.currentPage);
				int sumPag = dis.readInt();
				if (sumPag > 0) {
					window.totalPage = sumPag;
				}
				Tools.debugPrintln("totalPage = " + window.totalPage);

				window.m_unitIsRoll = null;
				window.m_unitRollx = null;
				int listCount = dis.readInt();
				Tools.debugPrintln("社交列表添加数量 : " + listCount);

				window.m_unitIsRoll = new boolean[listCount];//是否需要滚动
				window.m_unitRollx = new int[listCount];//滚动偏移量

				for (int i = 0; i < listCount; i++) {
					SimpleRole role = new SimpleRole();
					role.m_online = dis.readByte() == 0 ? true : false;// 是否在线
					// 0在线
					// 1不在线
					role.m_gameID = dis.readLong();
					role.m_name = dis.readUTF();
					Tools.debugPrintln("online = " + role.m_online);
					Tools.debugPrintln("id = " + role.m_gameID);
					Tools.debugPrintln("name = " + role.m_name);
					if (role.m_online) {
						role.m_race = dis.readByte();
						role.m_grade = dis.readInt();
						short size = dis.readShort();
						role.m_vocation = new byte[size];
						for (short j = 0; j < size; j++) {
							role.m_vocation[j] = dis.readByte();
						}
						Tools.debugPrintln("race = " + role.m_race);
						Tools.debugPrintln("grade = " + role.m_grade);
						Tools.debugPrintln("vocation = " + role.m_vocation);
					}
					if (listType == GameManager.SOCIAL_TYPE_FRIEND) {
						role.m_isGongFa = dis.readByte(); // 是否能攻伐
						role.m_isWatering = dis.readByte(); // 是否能浇水
					}
					GameManager.getInstance().m_social_list.addElement(role);

					//如果当前目标名字的长度大于显示框体设置需要滚动
					if (AbstractGameScreen.s_font.stringWidth(role.m_name) > (window.LISTNAME_NAME_WIDTH - (UITools.IW_RECT_CONTENT << 1))) {
						window.m_unitIsRoll[i] = true;
					}
					else {
						window.m_unitIsRoll[i] = false;
					}
					window.m_unitRollx[i] = 0;//单元的滚动偏移量
				}
				if (listCount <= 0) {
					window.memberIndex = -1;
				}
			}
			window.flag = true;
			window.registerTouch();
		}
		else {
			Tools.debugPrintln("读取社交界面异常 : " + msg);
		}
	}

	/**
	 * 读取添加玩家
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialAdd(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
		Tools.debugPrintln("state = " + state);
//		String msg = dis.readUTF();
		switch (state) {
			case 0:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"您不能添加自己为好友 ");
				break;
			case 1:
				break;
			case 2:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"您的好友列表已满");
				break;
			case 3:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"对方已经在您的好友列表当中");
				break;
			case 4:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"您已经向对方发送了好友请求，请耐心等待对方的确认");
				break;
			case 5:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"对方不在线");
				break;
			case 6:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"对方好友列表已满");
				break;
			case 7:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"对方已将您拉入黑名单");
				break;
			case 8:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"对方当前的状态不能做出回应，请稍后再试");
				break;
			case 9:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"您的黑名单列表已满");
				break;
			case 10:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"对方已经在您的黑名单中");
				break;
			case 11:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"对方拒绝了您的好友请求");
				break;
			case 12:
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
						"失败 对方和您不是一个阵营");
				break;

		}
		if (state == 1) {
			SimpleRole role = new SimpleRole();
			byte type = dis.readByte();
			role.m_gameID = dis.readLong();
			role.m_name = dis.readUTF();
			role.m_race = dis.readByte();
			role.m_grade = dis.readInt();
			short size = dis.readShort();
			role.m_vocation = new byte[size];
			for (short i = 0; i < size; i++) {
				role.m_vocation[i] = dis.readByte();
			}
			role.m_online = true;
			UISocialWindow win = null;
			switch (type) {
				case GameManager.SOCIAL_TYPE_FRIEND:
					win = (UISocialWindow) UIManager.getInstance()
							.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
					break;
				case GameManager.SOCIAL_TYPE_BLACKLIST:
					win = (UISocialWindow) UIManager.getInstance()
							.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_BLACK);
					break;
			}

			if (win != null) {
				if (GameManager.getInstance().m_social_list.size() < win.memberPageNum) {
					synchronized (win) {

						int sizeli2 = GameManager.getInstance().m_social_list.size();
						GameManager.getInstance().m_social_list.insertElementAt(role,
								sizeli2 == 0 ? 0 : (sizeli2 - 1));
						//如果当前目标名字的长度大于显示框体设置需要滚动
						int listsize = GameManager.getInstance().m_social_list.size();
						boolean isroll[] = new boolean[listsize];
						int rollx[] = new int[listsize];
						if (win.m_unitIsRoll == null) {
							win.m_unitIsRoll = new boolean[1];
						}
						else {
							int length = win.m_unitIsRoll.length;
							for (int j = 0; j < length; j++) {
								isroll[j] = win.m_unitIsRoll[j];
								rollx[j] = win.m_unitRollx[j];
							}

						}
						if (AbstractGameScreen.s_font.stringWidth(role.m_name) > (win.LISTNAME_NAME_WIDTH - (UITools.IW_RECT_CONTENT << 1))) {
							isroll[listsize - 1] = true;
						}
						else {
							isroll[listsize - 1] = false;
						}

						win.m_unitIsRoll = isroll;
						rollx[listsize - 1] = 0;
						win.m_unitRollx = rollx;//单元的滚动偏移量
					}
				}
				win.registerTouch();
			}

		}
		else {
			Tools.debugPrintln("读取添加玩家失败 : ");
		}
	}

	/**
	 * 读取删除玩家
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialDelete(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
//		String msg = dis.readUTF();
		if (state == 1) {
			byte type = dis.readByte();
			long id = dis.readLong();
			UISocialWindow window = null;
			Vector socialList = GameManager.getInstance().m_social_list;
			int size = socialList.size();
			switch (type) {
				case GameManager.SOCIAL_TYPE_FRIEND:
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
							"您已经与对方解除好友关系");
					window = (UISocialWindow) UIManager.getInstance()
							.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
					if (window == null) {
						window = (UISocialWindow) UIManager.getInstance()
								.createWindow(UIWindowFactory.WINDOW_ID_SOCIAL_FRIEND);
					}
					for (int i = 0; i < size; i++) {
						long roleID = ((SimpleRole) socialList.elementAt(i)).m_gameID;
						if (id == roleID) {
							socialList.removeElementAt(i);
							for (int j = i; j < size; j++) {
								if (j != (size - 1)) {
									window.m_unitIsRoll[j] = window.m_unitIsRoll[j + 1];
									window.m_unitRollx[j] = window.m_unitRollx[j + 1];
								}
								else {

									boolean isroll[] = new boolean[size - 1];
									int roolx[] = new int[size - 1];
									if ((size - 1) != 0) {
										for (int k = 0; k < (size - 1); k++) {
											isroll[k] = window.m_unitIsRoll[k];
											roolx[k] = 0;
										}
									}
									window.m_unitIsRoll = isroll;
									window.m_unitRollx = roolx;
								}
							}
							break;
						}
					}
					break;
				case GameManager.SOCIAL_TYPE_BLACKLIST:
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C,
							"您已经将对方移出黑名单");
					window = (UISocialWindow) UIManager.getInstance()
							.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_BLACK);
					if (window == null) {
						window = (UISocialWindow) UIManager.getInstance()
								.createWindow(UIWindowFactory.WINDOW_ID_SOCIAL_BLACK);
					}
					for (int i = 0; i < socialList.size(); i++) {
						long roleID = ((SimpleRole) socialList.elementAt(i)).m_gameID;
						if (id == roleID) {
							socialList.removeElementAt(i);
							for (int j = i; j < size; j++) {
								if (size < 2) {
									window.m_unitIsRoll = null;
									window.m_unitRollx = null;
									break;
								}
								window.m_unitIsRoll[j] = window.m_unitIsRoll[j + 1];
								window.m_unitRollx[j] = window.m_unitRollx[j + 1];
							}
							break;
						}
					}
					break;
			}
			if (window != null) {
				window.registerTouch();
			}
		}
		else {
			Tools.debugPrintln("读取删除玩家异常 : ");
		}
	}

	private final static byte REJECT = 0;// 拒绝
	private final static byte AGREE = 1;// 同意

	/**
	 * 添加好友确认信息
	 * 
	 * @param dis
	 */
	public static void recvSocialConfirmation(DataInputStream dis)
			throws IOException
	{
		String msg = dis.readUTF();
		final SimpleRole role = new SimpleRole();
		role.m_gameID = dis.readLong();
		role.m_name = dis.readUTF();
		role.m_race = dis.readByte();
		role.m_grade = dis.readInt();
		short size = dis.readShort();
		role.m_vocation = new byte[size];
		for (short i = 0; i < size; i++) {
			role.m_vocation[i] = dis.readByte();
		}
		final UIMessageBox msgwin = (UIMessageBox) UIManager.getInstance()
				.createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		msgwin.setMessage("好友邀请", "同意", "不同意", msg);
		msgwin.addListener(new UIListener() {
			public void actionPerformed()
							{
								if (AbstractGameScreen
										.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
										|| AbstractGameScreen
												.haveKeyPressed(AbstractGameScreen.GK_A)) {
									GameManager.getInstance().m_social_list.addElement(role);
									GameManager.getInstance().m_game_message
											.sendSocialConfirmation(AGREE, role.m_gameID);
									UIManager.getInstance().removeWindow(msgwin);
								}
								else if (AbstractGameScreen
										.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
									GameManager.getInstance().m_game_message
											.sendSocialConfirmation(REJECT, role.m_gameID);
									UIManager.getInstance().removeWindow(msgwin);

								}
							}
		});
	}

	/**
	 * 读取仇敌界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialEnemyList(DataInputStream dis)
			throws IOException
	{
		GameManager.getInstance().m_game_message.unlockNetwork();
		GameManager.getInstance().m_social_list.removeAllElements();
		Vector enemyList = GameManager.getInstance().m_social_list;
		UISocialWindow window = (UISocialWindow) UIManager.getInstance()
				.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY);
		if (window == null) {
			window = (UISocialWindow) UIManager.getInstance().createWindow(
					UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY);
		}
		window.flag = false;
		window.m_unitIsRoll = null;
		window.m_unitRollx = null;
		byte state = dis.readByte(); //当前状态
		if (state == 1) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C, "页号错误");
			return;
		}
		byte ishavedongfu = dis.readByte(); //0：无洞府1：有洞府
		window.m_dongfu_is_have = ishavedongfu;
		if (ishavedongfu == 1) {
			window.m_dongfu_nextTime_Gongfa = dis.readLong(); //下一次攻伐的时间  单位秒
//			window.m_dongfu_GongFa_interval = dis.readInt(); //攻伐时间间隔
			window.m_dongfu_GongFa_surplus = dis.readByte();// 攻伐剩余次数
		}
		short totalPage = dis.readShort(); //总页数

		if (totalPage == 0) {
			window.currentPage = 0;
			window.totalPage = totalPage + 1;
			return;
		}
		short currentPage = dis.readShort(); //当前页数

		window.currentPage = currentPage;
		window.totalPage = totalPage;

		short enemyNum = dis.readShort();// 仇敌数量		
		window.m_unitIsRoll = new boolean[enemyNum];//是否需要滚动
		window.m_unitRollx = new int[enemyNum];//滚动偏移量
		for (int i = 0; i < enemyNum; i++) {
			SimpleRole role = new SimpleRole();

			role.m_gameID = dis.readLong();
			role.m_name = dis.readUTF();
			role.m_is_Locked = dis.readByte() == 1 ? true : false;// 是否 锁定 0 未锁定
			role.m_HatredDegrees = dis.readUTF(); // 仇恨度
			Tools.debugPrintln("m_HatredDegrees = " + role.m_HatredDegrees);
			if (ishavedongfu == 1) {
				role.m_isGongFa = dis.readByte(); //是否可以攻伐 //
			}
			// 1 锁定
			role.m_online = dis.readByte() == 1 ? true : false;// 是否在线 0离线 1在线
			Tools.debugPrintln("online = " + role.m_online);
			Tools.debugPrintln("id = " + role.m_gameID);
			Tools.debugPrintln("name = " + role.m_name);

			if (role.m_online) {
				role.m_grade = dis.readShort(); // 等级
			}

			enemyList.addElement(role);

			//如果当前目标名字的长度大于显示框体设置需要滚动
			if (AbstractGameScreen.s_font.stringWidth(role.m_name) > (window.LISTNAME_NAME_WIDTH - (UITools.IW_RECT_CONTENT << 1))) {
				window.m_unitIsRoll[i] = true;
			}
			else {
				window.m_unitIsRoll[i] = false;
			}
			window.m_unitRollx[i] = 0;//单元的滚动偏移量
		}
		if (enemyNum <= 0) {
			window.memberIndex = -1;
		}
		window.flag = true;
		window.registerTouch();
	}

	/**
	 * 查看仇敌详细信息
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialEnemyInfo(DataInputStream dis)
			throws IOException
	{

	}

	/**
	 * 仇敌的具体位置
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialEnemyPosition(DataInputStream dis)
			throws IOException
	{
		short state = dis.readShort();// 0失败1成功
		String msg = dis.readUTF(); // 失败有
		if (state == 0) {
			GameManager.getInstance().addSystemInfo(
					GameManager.SYSTEM_INFO_TYPE_C, msg);
			return;
		}
		String location = dis.readUTF(); // 仇敌具体位置
		String name = dis.readUTF();
		final UIMessageBox msgbox = (UIMessageBox) UIManager.getInstance()
				.createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		msgbox.setMessage(null, "确定", "返回", name + "当前所在的位置： " + location);
		msgbox.addListener(new UIListener() {
			public void actionPerformed()
							{
								if (AbstractGameScreen
										.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
										|| AbstractGameScreen
												.haveKeyPressed(AbstractGameScreen.GK_A)) {
									UIManager.getInstance().removeWindow(msgbox);
								}
								else if (AbstractGameScreen
										.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
									UIManager.getInstance().removeWindow(msgbox);
								}
							}
		});
	}

	/**
	 * 删除仇敌
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialEnemyDelete(DataInputStream dis)
			throws IOException
	{
		short state = dis.readShort(); // 0失败1成功
		String msg = dis.readUTF(); // 失败有
		long enemyID = dis.readLong();// 仇敌ＩＤ
		if (state == 0) {
			GameManager.getInstance().addSystemInfo(
					GameManager.SYSTEM_INFO_TYPE_C, msg);
		}
		else if (state == 1) {
			UISocialWindow window = (UISocialWindow) UIManager.getInstance()
					.getWindowById(UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY);
			if (window == null) {
				window = (UISocialWindow) UIManager.getInstance()
						.createWindow(UIWindowFactory.WINDOW_ID_SOCIAL_ENEMY);
			}
			Vector list = GameManager.getInstance().m_social_list;
			int size = list.size();
			for (int i = 0; i < size; i++) {
				long roleID = ((SimpleRole) list.elementAt(i)).m_gameID;
				if (enemyID == roleID) {
					list.removeElementAt(i);
					for (int j = i; j < size - 1; j++) {
						if (size < 2) {
							window.m_unitIsRoll = null;
							window.m_unitRollx = null;
						}
						else {
							window.m_unitIsRoll[j] = window.m_unitIsRoll[j + 1];
							window.m_unitRollx[j] = window.m_unitRollx[j + 1];
						}
					}
					break;
				}
			}
			window.registerTouch();
		}
	}

	/**
	 * 发布通缉令
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialEnemyWanted(DataInputStream dis)
			throws IOException
	{
		GameManager.getInstance().m_game_message.unlockNetwork();
		short state = dis.readShort(); // 0 失败 1成功		
		String msg = dis.readUTF(); // 失败有
		GameManager.getInstance().addSystemInfo(
				GameManager.SYSTEM_INFO_TYPE_B, msg);
	}

	/**
	 * 锁定仇敌
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvSocialEnemyLock(DataInputStream dis)
			throws IOException
	{
		short state = dis.readShort(); // 0失败1成功
		String msg = dis.readUTF(); // 失败有
		long m_id = dis.readLong(); // 请求锁定玩家的ID
		Vector list = GameManager.getInstance().m_social_list;
		if (state == 1) {
			int size = list.size();
			for (int i = 0; i < size; i++) {
				SimpleRole role = (SimpleRole) list.elementAt(i);
				if (m_id == role.m_gameID) {
					role.m_is_Locked = true;
				}
			}
		}
		else {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C, msg);
		}
	}

	/**
	 * 读取洞府攻伐界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public static void recvDongFuGongFa(DataInputStream dis) throws IOException
	{
		GameManager.getInstance().m_game_message.unlockNetwork();
		short cpg = dis.readShort(); //当前页
		short tpg = dis.readShort(); //总页数
		short size = dis.readShort(); //玩家数
		UISocialWindow gongfaUI = (UISocialWindow) UIManager.getInstance().getWindowById(
				UIWindowFactory.WINDOW_ID_DONGFU_GONGFA);
		if (gongfaUI != null) {
			gongfaUI.currentPage = cpg;
			if (tpg > 0) {
				gongfaUI.totalPage = tpg;
			}
			GameManager.getInstance().m_social_list.removeAllElements();
			Vector list = GameManager.getInstance().m_social_list;
			for (int i = 0; i < size; i++) {
				SimpleRole role = new SimpleRole();
				role.m_gameID = dis.readLong();
				role.m_name = dis.readUTF();
				role.m_jbp_grade = dis.readByte();
				role.m_faction = dis.readByte();
				list.addElement(role);
			}
			gongfaUI.registerTouch();
		}

	}

	/**
	 * 读取夫妻界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialCouple(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 读取结义界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialBrother(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 读取家族成员界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialClan(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 读取师傅界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialMaster(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 读取徒弟界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialApprentice(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 读取黑名单界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialBlacklist(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 放入名字的输入框
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param isSel 是否选中
	 */
	private static final void paintInputRectSocial(Graphics g, int x, int y, int w, int h, String str[], boolean isSel)
	{
		paintRectStrSocial(g, x, y, w, h, str, isSel);
	}

	/**
	 * 输入带有文字的内容框，其中文字颜色及内框颜色可定制
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param color_rect
	 * @param str_col
	 * @param content
	 */
	private static final void paintRectStrSocial(Graphics g, int x, int y, int w, int h,
			String content[], boolean isSel)
	{
		if (isSel) {
			UITools.fillContentRect(g, x, y, w, h, UIManager.getPaletteColor(UIManager.COLOR_RECT_SEL));
		}
		else {
			UITools.paintContentRect(g, x, y, w, h);
		}
		if (content == null || content.equals("")) {
			return;
		}
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
//		String string[] = Tools.splitString(content, AbstractGameScreen.s_font, '|', w - 4);
		int font_height = AbstractGameScreen.s_font.getHeight() + 1;
		if (content != null && content.length != 0) {
			g.setClip(x, y, w, h);
			for (int i = 0; i < content.length; i++) {
				g.drawString(content[i], x + 4, y + font_height * i + 1,
						Tools.LEFT_TOP);
			}

		}
	}

	/**
	 * 根据列表的数据的下标 找到对应人物的ID
	 * 
	 * @return role.m_gameID
	 */
	private long getIndexID()
	{
		Vector sociallist = GameManager.getInstance().m_social_list;
		if (memberIndex > sociallist.size() - 1 || sociallist == null || sociallist.size() == 0) {
			return 0;
		}
		SimpleRole role = new SimpleRole();
		Vector roleList = GameManager.getInstance().m_social_list;
		role = (SimpleRole) roleList.elementAt(memberIndex);
		return role.m_gameID;
	}

	/**
	 * 根据列表的数据的下标 找到对应人物的name
	 * 
	 * @return role.m_gameID
	 */
	private String getIndexName()
	{
		Vector sociallist = GameManager.getInstance().m_social_list;
		if (memberIndex > sociallist.size() - 1 || sociallist == null || sociallist.size() == 0) {
			return "";
		}
		SimpleRole role = new SimpleRole();
		Vector roleList = GameManager.getInstance().m_social_list;
		role = (SimpleRole) roleList.elementAt(memberIndex);
		return role.m_name;
	}

	/**
	 * 根据列表的数据的下标 找到对应人物是否能浇水
	 * 
	 * @return role.m_gameID
	 */
	private byte getIndexIsWatering()
	{
		if (memberIndex > GameManager.getInstance().m_social_list.size() - 1) {
			return -1;
		}
		SimpleRole role = new SimpleRole();
		Vector roleList = GameManager.getInstance().m_social_list;
		role = (SimpleRole) roleList.elementAt(memberIndex);
		return role.m_isWatering;
	}

	/**
	 * 根据列表的数据的下标 找到对应人物是否能攻伐
	 * 
	 * @return role.m_gameID
	 */
	private boolean getIndexIsWar()
	{
		if (memberIndex > GameManager.getInstance().m_social_list.size() - 1) {
			return false;
		}
		SimpleRole role = new SimpleRole();
		Vector roleList = GameManager.getInstance().m_social_list;
		role = (SimpleRole) roleList.elementAt(memberIndex);
		return role.m_isGongFa == 1 ? true : false;
	}

	private void gotoWantedwrite()
	{

		final Form myForm = new Form("通缉令输入");
		String name = null;
		if (m_enemy_subMenu_index == 0) {
			name = "请输入金币的数量:";
		}
//		else if (m_enemy_subMenu_index == 1) {
//			name = "请输入银票的数量:";
//		}
		else if (m_enemy_subMenu_index == 1) {
			name = "请输入榜文:";
		}
		final TextField textField1 = new TextField(name, "", 30, TextField.ANY);
		myForm.append(textField1);
		final StringItem warnInfoItem = new StringItem("", "");
		myForm.append(warnInfoItem);
		final Command ok = new Command("确定", Command.OK, 1);
		final Command cancel = new Command("返回", Command.CANCEL, 1);
		myForm.addCommand(ok);
		myForm.addCommand(cancel);
		myForm.setFormButtons();
		CommandListener listener = new CommandListener() {

			public void commandAction(Command c, Displayable d)
							{
								if (c == ok) {
									if (m_enemy_subMenu_index == 0) {
										String jinbi = textField1.getString();

										if (isInputNumber(jinbi)) {
											int jinbiNum = Integer.parseInt(jinbi);
											if (jinbiNum >= 2) {
												m_enemy_jinbi_num = jinbiNum;
												Display.getDisplay(GameMIDlet.s_instance).setCurrent(
														GameMIDlet.s_canvas);
											}
											else {
												warnInfoItem.setLabel("提示 :");
												warnInfoItem.setText("悬赏金额不能小于两金!");
											}
										}
										else {
											warnInfoItem.setLabel("提示 :");
											warnInfoItem.setText("输入的字符必须是数字!");
										}

									}
//									else if (m_enemy_subMenu_index == 1) {
//										String yuanbao = textField1.getString();
//										if (isInputNumber(yuanbao)) {
//											int yuanbaoNum = Integer.parseInt(yuanbao);
//											if (yuanbaoNum >= 2) {
//												m_enemy_yuanbao_num = yuanbaoNum;
//												Display.getDisplay(GameMIDlet.s_instance).setCurrent(
//														GameMIDlet.s_canvas);
//											}
//											else {
//												warnInfoItem.setLabel("提示 :");
//												warnInfoItem.setText("悬赏金额不能小于银票!");
//											}
//										}
//										else {
//											warnInfoItem.setLabel("提示 :");
//											warnInfoItem.setText("输入的字符必须是数字!");
//										}
//									}
									else if (m_enemy_subMenu_index == 1) {
										String msg = textField1.getString();
										if (msg.length() < 30) {
											m_enemy_msg = Tools.splitString(msg, AbstractGameScreen.s_font, '|',
													enemyStringMsg_w - 4);
											Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
										}
										else {
											warnInfoItem.setLabel("提示 :");
											warnInfoItem.setText("输入的字符不能超过30个!");
										}
									}
								}
								else if (c == cancel) {
									Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
								}
							}
		};
		myForm.setCommandListener(listener);
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(myForm);

	}

	/**
	 * 检查是否为纯数字
	 * @param text
	 * @return
	 */
	private boolean isInputNumber(String text)
	{
		for (int j = 0; j < text.length(); j++) {
			if (text.charAt(j) < 48 || text.charAt(j) > 57) {
				return false;
			}
		}

		return true;
	}

	// 在好友界面子菜单点击添加好友,进入高级界面
	private void gotoFriendWriteContentFrom()
	{
		final Form myForm = new Form("添加好友输入");
		final TextField textField1 = new TextField("请输入要添加好友的玩家姓名", "", 20,
				TextField.ANY);
		myForm.append(textField1);
		final StringItem warnInfoItem = new StringItem("", "");
		myForm.append(warnInfoItem);
		final Command ok = new Command("确定", Command.OK, 1);
		final Command cancel = new Command("返回", Command.CANCEL, 1);
		myForm.addCommand(ok);
		myForm.addCommand(cancel);
		myForm.setFormButtons();
		CommandListener listener = new CommandListener() {

			public void commandAction(Command c, Displayable d)
							{
								if (c == ok) {
									if (textField1.getString() == "") {
										warnInfoItem.setLabel("请输入玩家姓名");
									}
									else {
										Display.getDisplay(GameMIDlet.s_instance).setCurrent(
												GameMIDlet.s_canvas);
										GameManager.getInstance().m_game_message
												.sendSocialAddForName(
														GameManager.SOCIAL_TYPE_FRIEND,
														textField1.getString());
									}
								}
								else if (c == cancel) {
									Display.getDisplay(GameMIDlet.s_instance).setCurrent(
											GameMIDlet.s_canvas);
								}
							}
		};
		myForm.setCommandListener(listener);
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(myForm);
	}

	private void gotoBlacekWriteContentFrom()
	{
		final Form myForm = new Form("添加黑名单输入");
		final TextField textField1 = new TextField("请输入要添加黑名单的玩家姓名", "", 20,
				TextField.ANY);
		myForm.append(textField1);
		final StringItem warnInfoItem = new StringItem("", "");
		myForm.append(warnInfoItem);
		final Command ok = new Command("确定", Command.OK, 1);
		final Command cancel = new Command("返回", Command.CANCEL, 1);
		myForm.addCommand(ok);
		myForm.addCommand(cancel);
		myForm.setFormButtons();
		CommandListener listener = new CommandListener() {

			public void commandAction(Command c, Displayable d)
							{
								if (c == ok) {
									if (textField1.getString() == "") {
										warnInfoItem.setLabel("请输入玩家姓名");
									}
									else {
										Display.getDisplay(GameMIDlet.s_instance).setCurrent(
												GameMIDlet.s_canvas);
										GameManager.getInstance().m_game_message
												.sendSocialAddForName(
														GameManager.SOCIAL_TYPE_BLACKLIST,
														textField1.getString());
									}
								}
								else if (c == cancel) {
									Display.getDisplay(GameMIDlet.s_instance).setCurrent(
											GameMIDlet.s_canvas);
								}
							}
		};
		myForm.setCommandListener(listener);
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(myForm);
	}

	/**
	 * 查看玩家属性
	 */
	private void seeRole()
	{
		GameManager.getInstance().m_game_message.sendAttInfos(getIndexID());
	}

	/**
	 * 写信
	 */
	private void writeMail()
	{
		UIMail.sendMailToPlayer(getIndexName());
	}

	/**
	 * 私聊
	 */
	private void writeMsg()
	{
		UIChatInsert.gotoSiliao(getIndexID(), getIndexName());
	}

	/**
	 * 交易
	 */
	private void Deal()
	{

		GameManager.getInstance().m_game_message.sendDealRequest(getIndexID());
	}

	/**
	 * 销毁
	 */
	protected void close()
	{
		super.close();
		GameManager.getInstance().m_social_list.removeAllElements();
		super.dispose();
	}

	public int m_currframeCount;
	private boolean[] m_unitIsRoll;//单元区域是否需要滚动
	public int[] m_unitRollx;//单元区域的滚动

	private final int ROLL_STARTTIME = 20;//单元开始滚动的固定时间
	private final int ROLL_OVERTIME = 10;//单元滚动结束等待还原的固定时间
	private int m_rollState;//单元当前滚动状态  ：0开始等待 1滚动中 2滚动结束等待中
	private int m_frameCount = 0;//计算单元滚动时间 用帧数计算

	private void unitRollx()
	{
		if (m_unitIsRoll == null || m_unitRollx == null || memberIndex >= m_unitIsRoll.length || memberIndex < 0) {
			return;
		}
		if (m_unitIsRoll[memberIndex]) {//判断滚动处理  条件必须是当前选中的单元需要滚动
			switch (m_rollState) {//当前需要滚动单元的状态
				case 0://开始等待
					if (m_frameCount == 0) {
						//m_frameCount = GameManager.getInstance().m_scene.m_frameCount; 
						m_frameCount = m_currframeCount;
					}
					else if (m_currframeCount - m_frameCount >= ROLL_STARTTIME) {
						m_rollState = 1;
						m_frameCount = 0;
					}
					break;
				case 1://滚动中
					if (m_unitRollx[memberIndex] < LISTNAME_NAME_WIDTH - (UITools.IW_RECT_CONTENT << 1)) {
						m_unitRollx[memberIndex]++;
					}
					else {
						m_rollState = 2;
					}
					break;
				case 2://结束等待
					if (m_frameCount == 0) {
						//m_frameCount = GameManager.getInstance().m_scene.m_frameCount;
						m_frameCount = m_currframeCount;
					}
					else if (m_currframeCount - m_frameCount >= ROLL_OVERTIME) {
						m_rollState = 0;
						m_frameCount = 0;
						m_unitRollx[memberIndex] = 0;
					}
					break;
			}
		}
		//判断如果当前选项离开充值便宜量
		for (int i = 0; i < m_unitRollx.length; i++) {
			if (m_unitRollx[i] != 0 && memberIndex != i) {
				m_unitRollx[i] = 0;
				break;
			}
		}
	}

	/******************* 图片 *********************/
	private Image img_dongfu_watering = null; // 洞府小水滴
	private Image img_dongfu_war = null; // 洞府攻伐

	/******************* 坐标,宽高 *********************/
	//#if screen == "640360"
	 private final int LISTNAME_NAME_WIDTH = 120; // 玩家姓名标题w和列表
	//#else
//	private final int LISTNAME_NAME_WIDTH = 82; // 玩家姓名标题w和列表
	//#endif
	private final int LISTNAME_NAME_WIDTH3 = 110; // 玩家姓名标题w和列表:3
	private final int LISTNAME_OTHER_WIDTH3 = 40; // 其它标题W和列表

	private final int LISTNAME_OTHER_WIDTH = 36; // 其它标题W和列表
	private final int LISTNAME_HEIGHT = 23;// 所有标题H
	private final int LIST_SPACE = 2; // 标题自间的间隔

	private final int LISTNAME_NAME_X = UITools.X_BG
			+ ((UITools.W_BG - LISTNAME_NAME_WIDTH - LISTNAME_OTHER_WIDTH * 3 - LIST_SPACE * 3) >> 1); // 玩家名字标题X
	private final int LISTNAME_NAME_Y = UITools.Y_BG + UITools.INITY_CONTENT; // 玩家名字标题Ｙ

	private final int LIST_FRAME_X = LISTNAME_NAME_X; // 玩家姓名列表x
	private final int LIST_FRAME_Y = LISTNAME_NAME_Y + LISTNAME_HEIGHT + LIST_SPACE;// 玩家姓名列表Y
	private final int LIST_RECT_H = 24; // 列表高 ，通用 、内

	public int memberIndex = 0; // 当前成员下标列表

//	private final int LIST_HELGHT = UITools.H_BG - (LISTNAME_HEIGHT + LIST_SPACE+ AbstractGameScreen.FONT_H);// 所有列表的高
	private final int LIST_HELGHT = UITools.H_RECT - (LISTNAME_HEIGHT + UITools.IH_RECTS) - (AbstractGameScreen.FONT_H);

	private final int memberPageNum = LIST_HELGHT / LIST_RECT_H; // 当前一页显示成员数
	private final int STRING_LIST_Y = (LIST_RECT_H - AbstractGameScreen.FONT_H) >> 1; //文字顶部距离

	/** 仇敌相关 */
	public int m_enemyStatus = 0;
	private final int m_background_fill_w = 200; // 背景宽
	private final int m_background_fill_h = 230;// 背景高
	private final int m_background_fill_x = UITools.X_BG + UITools.INITX_CONTENT;
	private final int m_background_fill_y = UITools.Y_BG + UITools.INITY_CONTENT;;
	private int enemyStringOneLine_lable_x = m_background_fill_x + 11; // 第一行字标题
	private int enemyStringOneLine_contents_x = m_background_fill_x + 78;
	private int enemyStringOneLine_y = m_background_fill_y + 25;
	private int enemyStringNum = 20; // 偏移量

	private int enemyMoneyAward_x = enemyStringOneLine_contents_x;
	private int enemyMoneyAward_y = m_background_fill_y + 85;
	private int enemyMoneyAward_w = 79;
	private int enemyMoneyAward_h = 22;

	private int enemyStringMsg_x = m_background_fill_x + 13;
	private int enemyStringMsg_y = m_background_fill_y + 144;
	private int enemyStringMsg_w = 170;
	private int enemyStringMsg_h = 60;

	String FaBuTongJiLing[] = { "通缉目标:", "目标等级：", "击杀时限:", "奖金数额：", "通缉榜文：（30字）", "手续费:" }; //发布通缉令界面数组
	String FABUTONGJI = "发布通缉令";

	private byte m_dongfu_is_have; //玩家自己是否有洞府
	private long m_dongfu_nextTime_Gongfa;// 下一次攻伐的时间  单位秒
//	private int m_dongfu_GongFa_interval; //攻伐时间间隔
	private byte m_dongfu_GongFa_surplus; //攻伐剩余次数
//	private static final String isLockTrue = "是";
//	private static final String isLockFalse = "否";

	//服务器发的攻伐列表
//	private ArrayList m_dongfu_gongfaList;
	public final String[] FACTION_WORD = { "任意", "纯阳", "灵隐", "中立", "敌对", "天机" };
}
